/*            Copyright(c) 2006-2008 Dave Sexton           *
 * http://www.codeplex.com/DocProject                      *
 * http://www.codeplex.com/DocProject/Project/License.aspx *
 ***********************************************************/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DaveSexton.DocProject.Resources;

namespace DaveSexton.DocProject
{
	// A bug in the designer is causing the form's size to change every time it's saved and then reopened.  The problem seems to be 
	// with setting the MinimumSize property (it's adding 26 to the height each time, presumably the size of the title bar)
	// To work around this bug I've subtracted 26 from the MinimumSize.Height in the designer's property grid and then resized the form to the 
	// appropriate height (230 should be the true minimum height, and that's the height of the form in the designer).
	partial class IncludeOutputMessageBox : Form
	{
		#region Public Properties
		/// <summary>
		/// Gets or sets whether the <b>Don't ask me this again</b> <see cref="CheckBox" /> is checked.
		/// </summary>
		public bool DontAskMeAgainChecked
		{
			get
			{
				return dontAskAgainCheckBox.Checked;
			}
		}

		/// <summary>
		/// Gets or sets whether the <b>Apply to all</b> <see cref="CheckBox" /> is checked.
		/// </summary>
		public bool ApplyToAllChecked
		{
			get
			{
				return applyToAllCheckBox.Checked;
			}
			set
			{
				applyToAllCheckBox.Checked = value;
			}
		}

		/// <summary>
		/// Gets or sets the name of the project as it will appear in the question label.
		/// </summary>
		[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
		public string ProjectName
		{
			get
			{
				return projectName;
			}
			set
			{
				projectName = value;
				questionLabel.Text = string.Format(System.Globalization.CultureInfo.CurrentCulture, questionFormat, projectName);
			}
		}

		/// <summary>
		/// Gets or sets the build item in question.
		/// </summary>
		[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
		public string BuildItem
		{
			get
			{
				return buildItemLabel.Text;
			}
			set
			{
				buildItemLabel.Text = value;
			}
		}
		#endregion

		#region Private / Protected
		private readonly string questionFormat;
		private string projectName;
		#endregion

		#region Constructors
		/// <summary>
		/// Constructs a new instance of the <see cref="IncludeOutputMessageBox" /> class.
		/// </summary>
		public IncludeOutputMessageBox()
		{
			InitializeComponent();

			questionFormat = questionLabel.Text;

			Bitmap bitmap = Images.Question;
			bitmap.MakeTransparent(Color.Red);

			picture.Image = bitmap;
		}
		#endregion

		#region Event Handlers
		protected override void OnPaint(PaintEventArgs e)
		{
			base.OnPaint(e);

			TextRenderer.DrawText(e.Graphics, buildItemLabel.Text, Font, buildItemLabel.Bounds, ForeColor,
				TextFormatFlags.PathEllipsis | TextFormatFlags.NoPrefix | TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter);
		}

		private void btnYes_Click(object sender, EventArgs e)
		{
			DialogResult = DialogResult.Yes;
		}

		private void btnNo_Click(object sender, EventArgs e)
		{
			DialogResult = DialogResult.No;
		}

		private void chkDontAskAgain_CheckedChanged(object sender, EventArgs e)
		{
			if (dontAskAgainCheckBox.Checked)
			{
				applyToAllCheckBox.Checked = true;
				applyToAllCheckBox.Enabled = false;
			}
			else
				applyToAllCheckBox.Enabled = true;
		}
		#endregion
	}
}